﻿

namespace Mulala.Cavan.Presentation.Mvc.ViewModel
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mulala.Cavan.Domain.MainBoundedContext.AttachmentModule;
    using Mulala.Cavan.Presentation.Seedwork;
    using Mulala.Cavan.Domain.MainBoundedContext.Setting;

    public class CorporationPhotoViewModelConverter
    {
        public static ICorporationPhotosViewModel Convert(IList<Attachment> corporationPhotos)
        {
            if (null == corporationPhotos)
            {
                return null;
            }
            ICorporationPhotosViewModel corporationPhotosViewModel = ModelFactory.CreateModel<ICorporationPhotosViewModel>();
            foreach (Attachment photo in corporationPhotos)
            {
                ICorporationPhotoViewModel corporationPhotoViewModel = ModelFactory.CreateModel<ICorporationPhotoViewModel>();
                corporationPhotoViewModel.Photo = Project.Settings.ImageServer + photo.FileUrl + photo.FileName;
                corporationPhotoViewModel.PhotoID = photo.ID;
                corporationPhotosViewModel.Photos.Add(corporationPhotoViewModel);
            }

            return corporationPhotosViewModel;
        }
    }
}
